﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UClaimDemageUpdateInStock : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.索赔件来往帐_旧件返回 };
            }
        }
        protected override string DWZRef
        {
            get { return "UClaimDemageList"; }
        }

        #region
        /// <summary>
        /// 需要修改的ID
        /// </summary>
        protected int ID
        {
            get
            {
                return GetRequestValue<int>("ID");
            }
        }

        private UClaimDemageInfo _obj;
        protected UClaimDemageInfo obj
        {
            get
            {
                if (_obj == null)
                    _obj = UClaimDemageController.GetById(ID);
                return _obj;
                //OMenuController.ge
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "updateinstock")
            {
                addmenu();
                
            }
            
        }

        protected void addmenu()
        {
            bool InStock = base.User.IsSuperAdmin ? GetRequestValue<bool>("InStock", true) : true;
            DateTime InDate = GetRequestValue<DateTime>("InDate", DateTime.Now);
            decimal InQuantity = GetRequestValue<decimal>("InQuantity", 0m);
            string InOrderNum = GetRequestValue<string>("InOrderNum", "");
            string InRemark = GetRequestValue<string>("InRemark", "");
            decimal InWuPan = GetRequestValue<decimal>("InWuPan", 0m);
            bool IsPan = GetRequestValue<bool>("IsPan",false);
            int  InGuiFan= GetRequestValue<int>("InGuiFan",0);
            string GoTrack = GetRequestValue<string>("GoTrack", "");
            string GOTrackDate = GetRequestValue<string>("GOTrackDate", "");

            if (InQuantity > 0)
                InStock = true;

            if (UClaimDemageController.UpdateInStock(ID, InStock, InDate, InQuantity, InOrderNum, InRemark, InWuPan, IsPan, InGuiFan, GoTrack, GOTrackDate))
            {
                AddLog(Permission.修改, obj);
                SuccessJson("修改成功", "");
            }
            else
                ErrorJson("修改失败","");

            
        }
    }
}